<?php
 
include('top.php');
require_once('pasmy/dbwaarden.php');
?> 
<h2><div style="text-align: center"><?php echo $dbzoeken[$taal];?></div></h2>
<?php
echo "<br><br>";
$mysql_id = mysql_connect($dbhost, $dbuser, $dbpass);
mysql_select_db($db, $mysql_id);

/*foreach($_GET as $key => $value) {
		echo "sleutel = $key en waarde = $value<br>";
	}*/


if($taal == fr) {
$maanden = array("-----","Janvier","Fevrier","Mars","Avril","Mai","Juin","Julliet","Aout","Septembre","Octobre","Novembre","Decembre");
}
else {
$maanden = array("-----","Januari","Februari","Maart","April","Mei","Juni","Juli","Augustus","September","Oktober","November","December");
}

$dagen = array("-----","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31");

$jaren = array("-----","2010","2011","2012","2013","2014","2015","2016","2017","2018","2019","2020");


if(isset($_POST["zoek"])) {

postwaarden();

if(empty($_POST["yy"]) or $_POST["yy"] == "-----") { $waardb = "vnzvrn" . $_POST["jaar"]; } else {$waardb = "vnzvrn" . $_POST["yy"];}
if(empty($_POST["yy1"]) or $_POST["yy1"] == "-----" ) { $waardb = "vnzvrn" . $_POST["jaar"]; } else {$waardb = "vnzvrn" . $_POST["yy1"];}
if(empty($_POST["yy2"]) or $_POST["yy2"] == "-----") { $waardb = "vnzvrn" . $_POST["jaar"]; } else {$waardb = "vnzvrn" . $_POST["yy2"];}

$sql = "Select * from `$waardb`";
if(!empty($_POST["driver"])) {
	$_POST["driver"] = mysql_real_escape_string($_POST["driver"]);
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";}	
	$sql .= "$ver `driver` like  '%$_POST[driver]%'";
	$en = 1;	
	}

if($_POST["jj"] == "-----") {
	$datum = $_POST["yy"] . "-" . $_POST["mm"] . "-" . $_POST["jj"];
	
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";}
	$sql .= " $ver `datum` like '$datum'";
	$en = 1;	
	}
if($_POST["jj1"] == "-----") {
	$datum1 = $_POST["yy1"] . "-" . $_POST["mm1"] . "-" . $_POST["jj1"];
	$datum2 = $_POST["yy2"] . "-" . $_POST["mm2"] . "-" . $_POST["jj2"];
	
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";}
	$sql .= " $ver `datum` >= '$datum1' and `datum` <= '$datum2'";
	$en = 1;
	
	}
if(!empty($_POST["ref"])) {
	$_POST["ref"] = mysql_real_escape_string($_POST["ref"]);
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `ref` like '%$_POST[ref]%'";
	$en = 1;
	}
if(!empty($_POST["client"])) {
	$_POST["client"] = mysql_real_escape_string($_POST["client"]);
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `client` like '%$_POST[client]%'";
	$en = 1;
	}
if(!empty($_POST["expedi"])) {
	$_POST["expedi"] = mysql_real_escape_string($_POST["expedi"]);
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `expediteur` like '%$_POST[expedi]%'";
	$en = 1;
	}
if(!empty($_POST["laadplaats"])) {
	$_POST["laadplaats"] = mysql_real_escape_string($_POST["laadplaats"]);
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `laadplaats` like '%$_POST[laadplaats]%'";
	$en = 1;
	}


if(!empty($_POST["desti"])) {
	$_POST["desti"] = mysql_real_escape_string($_POST["desti"]);
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `bestemmeling` like '%$_POST[desti]%'";
	$en = 1;
	}
if(!empty($_POST["ville"])) {
	$_POST["ville"] = mysql_real_escape_string($_POST["ville"]);
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `plaats` like '%$_POST[ville]%'";
	$en = 1;
	}
if(!empty($_POST["colis"])) {
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `colis` = '$_POST[colis]'";
	$en = 1;
	}
if(!empty($_POST["pal"])) {
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `pal` = '$_POST[pal]'";
	$en = 1;
	}
if(!empty($_POST["mp"])) {
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `mp` like '%$_POST[mp]%'";
	$en = 1;
	}
if(!empty($_POST["poids"])) {
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `poids` = '$_POST[poids]'";
	$en = 1;
	}
if(!empty($_POST["prix"])) {
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `prijs` like '%$_POST[prix]%'";
	$en = 1;
	}
if(!empty($_POST["week"])) {
	if ($en != 1) { $ver = " Where "; } else { $ver = "and";} 
	$sql .= " $ver `week` = '$_POST[week]'";
	$en = 1;
	}
$sql = $sql . " order by `datum`,`plaats`";
?>

<table border="1" width="100%" align="center">
<tr>
<td class="delsaux2"><?php echo $datum[$taal];?></td>
<td class="delsaux2"><?php echo $referentie[$taal];?></td>
<td class="delsaux2"><?php echo $klant[$taal];?></td>
<td class="delsaux2"><?php echo $verzender[$taal];?></td>
<td class="delsaux2"><?php echo $laplaats[$taal];?></td>
<td class="delsaux2"><?php echo $bestemmeling[$taal];?></td>
<td class="delsaux2"><?php echo $plaats[$taal];?></td>
<td class="delsaux2">Colis</td>
<td class="delsaux2"><?php echo $pals[$taal];?></td>
<td class="delsaux2"><?php echo $vloerm[$taal];?></td>
<td class="delsaux2"><?php echo $gewicht[$taal];?></td>
<td class="delsaux2"><?php echo $pprijs[$taal];?></td>
<td class="delsaux2">Chauffeur</td>
<td class="delsaux2"><?php echo $opmerkingen[$taal];?></td>
<?php
if($_SESSION['login'] < "22") {
		 echo "<td class='delsaux2'>Update</td>";
}
 
?>
</tr>

<?php
if($_SESSION['login'] == "0") {
echo "<b>sql = $sql<b></br><br />";	
}
$res = mysql_query($sql, $mysql_id);
/*if(empty($row[0])) { echo "<tr><td colspan='14'><br /><div style='text-align: center'>
<b>Aucun document ne correspond aux termes de recherche sp&eacute;cifi&eacute;s </b></div><br /></td></tr>";}*/
$dag = "0000-00-00";
while ($row = mysql_fetch_row($res)) {
	if($row[0] > $dag) {$nombre++;$dag = $row[0];}
	if ($nombre%2 == 1)
    $klasse = "#fdd4d4";
  else
    $klasse = "#a9dea0";
	
	$dagdatum = explode("-",$row[0]);
	$tota = $tota + $row[10];
	 echo "<tr bgcolor = '$klasse'>
	<td class = 'zones'>$dagdatum[2]-$dagdatum[1]-$dagdatum[0]</td>
	<td class = 'zones'>$row[1]</td>
	<td class = 'zones'><div style='text-align: center'>$row[2]</div></td>
	<td class = 'zones'><div style='text-align: center'>$row[3]</div></td>

	<td class = 'zones'><div style='text-align: center'>$row[15]</div></td>
	
	<td class = 'zones'><div style='text-align: center'>$row[4]</div></td>
	<td class = 'zones'><div style='text-align: center'>$row[5]</div></td>
	<td class = 'zones'><div style='text-align: center'>$row[6]</div></td>
	<td class = 'zones'><div style='text-align: center'>$row[7]</div></td>
	<td class = 'zones'><div style='text-align: center'>$row[8]</div></td>
	<td class = 'zones'><div style='text-align: center'>$row[9]</div></td>
	<td class = 'zones'><div style='text-align: center'>$row[10]</div></td>
	<td class = 'zones'><div style='text-align: center'>$row[12]</div></td>
	<td class = 'zones'>$row[11]</td>";
	if($_SESSION['login'] < "23") {

		echo "<td class = 'zones'><a href='pdt.php?nr=$row[14]&jaren=$waardb' class = 'linkblue'>Update</a></td>";
		
	}
	echo "</tr>";
	

}
mysql_free_result($res);
echo "<tr><td colspan='11'>&nbsp;</td><td class = 'delsaux'>$tota</td><td colspan='3'>&nbsp;</td></tr>";
echo "</table>";

}
else {
?>
<table align="center">
<form action="masszoeken2.php" method="post">
<tr>
<td><strong>Chauffeur</strong></td>
<td>
<input type="text" name="driver" size="25" maxlength="40" />
</td>
</tr>
<tr>
<td><strong><?php echo $jaar[$taal];?></strong></td>
<td>
<?php $jaartal = date("Y");?>
<input type="text" name="jaar" size="10" maxlength="40" value="<?php echo $jaartal;?>"/>
</td>
</tr>
<tr>
<td><strong><?php echo $datum[$taal];?></strong></td>
<td>

<select name="jj">
<?php
while(list($key, $val)=each($dagen)) {
	if (isset($dagen) && ($dagen == $val)) {
		echo '<option value="'.$val.'" selected>'.$val.'</option>';
	} else {
		echo '<option value="'.$val.'">'.$val.'</option>';
	}
}
?></select>

<!-- <input type="text" name="jj" size="2" maxlength="2" /> -->&nbsp;

<select name="mm">
<?php
while(list($key, $val)=each($maanden)) {
	if (isset($maanden) && ($maanden == $val)) {
		echo '<option value="'.$key.'" selected>'.$val.'</option>';
	} else {
		echo '<option value="'.$key.'">'.$val.'</option>';
	}
}
?></select>

<!-- <input type="text" name="mm" size="2" maxlength="2" /> -->&nbsp;

<select name="yy">
<?php
while(list($key, $val)=each($jaren)) {
	if (isset($jaren) && ($jaren == $val)) {
		echo '<option value="'.$val.'" selected>'.$val.'</option>';
	} else {
		echo '<option value="'.$val.'">'.$val.'</option>';
	}
}
?></select>

<!-- <input type="text" name="yy" size="4" maxlength="4" /> -->

</td>
</tr>
<tr>
<td><strong>Periode</strong></td>
<td>
<strong><?php echo $van[$taal];?></strong>&nbsp;&nbsp;

<?php reset($dagen);reset($maanden);reset($jaren);?>

<select name="jj1">
<?php
while(list($key, $val)=each($dagen)) {
	if (isset($dagen) && ($dagen == $val)) {
		echo '<option value="'.$val.'" selected>'.$val.'</option>';
	} else {
		echo '<option value="'.$val.'">'.$val.'</option>';
	}
}
?>
</select>

<!-- <input type="text" name="jj" size="2" maxlength="2" /> -->&nbsp;

<select name="mm1">
<?php
while(list($key, $val)=each($maanden)) {
	if (isset($maanden) && ($maanden == $val)) {
		echo '<option value="'.$key.'" selected>'.$val.'</option>';
	} else {
		echo '<option value="'.$key.'">'.$val.'</option>';
	}
}
?></select>

<!-- <input type="text" name="mm" size="2" maxlength="2" /> -->&nbsp;

<select name="yy1">
<?php
while(list($key, $val)=each($jaren)) {
	if (isset($jaren) && ($jaren == $val)) {
		echo '<option value="'.$val.'" selected>'.$val.'</option>';
	} else {
		echo '<option value="'.$val.'">'.$val.'</option>';
	}
}
?></select>
<!-- <input type="text" name="jj1" size="2" maxlength="2" />&nbsp; -->
<!-- <input type="text" name="mm1" size="2" maxlength="2" />&nbsp; -->
<!-- <input type="text" name="yy1" size="4" maxlength="4" />&nbsp;&nbsp; -->




<strong><?php echo $en[$taal];?></strong>&nbsp;&nbsp;
<?php reset($dagen);reset($maanden);reset($jaren);?>
<select name="jj2">
<?php
while(list($key, $val)=each($dagen)) {
	if (isset($dagen) && ($dagen == $val)) {
		echo '<option value="'.$val.'" selected>'.$val.'</option>';
	} else {
		echo '<option value="'.$val.'">'.$val.'</option>';
	}
}
?></select>

<!-- <input type="text" name="jj" size="2" maxlength="2" /> -->&nbsp;

<select name="mm2">
<?php
while(list($key, $val)=each($maanden)) {
	if (isset($maanden) && ($maanden == $val)) {
		echo '<option value="'.$key.'" selected>'.$val.'</option>';
	} else {
		echo '<option value="'.$key.'">'.$val.'</option>';
	}
}
?></select>

<!-- <input type="text" name="mm" size="2" maxlength="2" /> -->&nbsp;

<select name="yy2">
<?php
while(list($key, $val)=each($jaren)) {
	if (isset($jaren) && ($jaren == $val)) {
		echo '<option value="'.$val.'" selected>'.$val.'</option>';
	} else {
		echo '<option value="'.$val.'">'.$val.'</option>';
	}
}
?></select>
<!-- <input type="text" name="jj2" size="2" maxlength="2" />&nbsp; -->
<!-- <input type="text" name="mm2" size="2" maxlength="2" />&nbsp; -->
<!-- <input type="text" name="yy2" size="4" maxlength="4" /> -->
</td>
</tr>
<tr>
<td><strong><?php echo $referentie[$taal];?></strong></td>
<td><input type="text" name="ref" size="15" /></td>
</tr>
<tr>
<td><strong><?php echo $klant[$taal];?></strong></td>
<td><input type="text" name="client" size="15" /></td>
</tr>
<tr>
<td><strong><?php echo $verzender[$taal];?></strong></td>
<td><input type="text" name="expedi" size="15" /></td>
</tr>

<tr>
<td><strong><?php echo $laplaats[$taal];?></strong></td>
<td><input type="text" name="laadplaats" size="15" /></td>
</tr>

<tr>
<td><strong><?php echo $bestemmeling[$taal];?></strong></td>
<td><input type="text" name="desti" size="15" /></td>
</tr>
<tr>
<td><strong><?php echo $plaats[$taal];?></strong></td>
<td><input type="text" name="ville" size="15" /></td>
</tr>
<tr>
<td><strong>Colis</strong></td>
<td><input type="text" name="colis" size="15" /></td>
</tr>
<tr>
<td><strong><?php echo $pals[$taal];?></strong></td>
<td><input type="text" name="pal" size="15" /></td>
</tr>
<tr>
<td><strong><?php echo $vloermeter[$taal];?></strong></td>
<td><input type="text" name="mp" size="15" /></td>
</tr>
<tr>
<td><strong><?php echo $gewicht[$taal];?></strong></td>
<td><input type="text" name="poids" size="15" /></td>
</tr>
<tr>
<td><strong><?php echo $pprijs[$taal];?></strong></td>
<td><input type="text" name="prix" size="15" /></td>
</tr>
<tr>
<td><strong><?php echo $week[$taal];?></strong></td>
<td><input type="text" name="week" size="15" /></td>
</tr>
<tr>
<td><strong>Imprimer les remarques</strong></td>
<td><input type="checkbox" name="remark" value="ok" /></td>
</tr>

<tr><td colspan="2"><br /><div style="text-align: center"><input type="submit" name="zoek" value="<?php echo $zoeken[$taal];?>" /></div></td></tr>
</form>
</table>
<?php
}
include('footer.php');
?>